Jump to content

[SOLVED] where did i go wrong? New to PHP


ManOnScooter

Recommended Posts

I get just 1 value for the select query...

I just want to display the returned value

Where did i go wrong ??

 

<?php

$con = mysql_connect("localhost","root","administrator");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

  mysql_select_db("test", $con);

  $result = mysql_query("SELECT details FROM test where first_name like "%Scooter%"");

  $row = mysql_fetch_row($result);

  echo $row;

  mysql_close($con);

?>

Link to comment
Share on other sites

if you just want everything from the details column with no search creteria just do

 

<?php

$con = mysql_connect("localhost","root","administrator");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

  mysql_select_db("test", $con);

  $result = mysql_query("SELECT details FROM test);

  $row = mysql_fetch_row($result);

  echo $row;

  mysql_close($con);

?>

 

i think that will return everything from the details column. I am not sure as i cant test it as i am at work

Link to comment
Share on other sites

adam, that dint work..

 

This one worked

 

<?php

$con = mysql_connect("localhost","root","administrator");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

 

mysql_select_db("test", $con);

 

$result = mysql_query("SELECT details FROM test WHERE first_name LIKE '%scooter'");

 

while($row = mysql_fetch_array($result))

  {

 

  echo $row['details'];

 

  }

 

mysql_close($con);

?>

 

 

is there a way to do it without the while loop??

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.