php inserting preg_match_all array

Everest2205

New Member
this is a code to catch all url in the POST and shorting them then insert each of them in row in mysql ..... but here it is inserting all the url in one row ??so how can i make it catch the first url then insert it in database then go back for the second one and do the same..???\[code\]$urlinput=mysql_real_escape_string($_POST['url']); $pattren="/(http:\/\/)[a-zA-Z0-9]*\.[a-z]*(.*)|(www)\.[a-zA-Z0-9]*\.[com]*(.*)/";preg_match_all( $pattren, $urlinput, $matches );foreach($matches[0] as $match) {$id=rand(10000,99999);$shorturl=base_convert($id,20,36);$sql = "insert into url values('$id','$match','$shorturl')";mysql_query($sql,$con);}\[/code\]
 
Back
Top